const { TABLEMAP } = require("../config/table")
exports.TiaoYaQi_POST = async (ctx, next) => {
  //GIS_T_TZGYTYQ
  const { type, sbbh } = ctx.request.body
  // const { type, sbbh } = ctx.querys
  try {
    const pool =ctx.app.mssqlPool
    const {recordset} = await pool.query(`SELECT * FROM [dbo].[${TABLEMAP[type]}] WHERE SBBH IN ('${sbbh.join("','")}')`)
    // console.log(recordset.recordset)
    ctx.body = recordset
    // ctx.body = { type, sbbh }
  } catch (error) {
    console.log(error)
    ctx.body = '请检查url';
    ctx.status = 404;
  }
}
exports.getList = async (ctx, next) => {
  // ctx.router available
  try {
    const pool = ctx.app.mssqlPool
    const body = await pool.query(`SELECT  SBBH FROM [dbo].[GIS_T_TZGYTYQ]`)
    //  ctx.status = 200;
    //  ctx.type = 'application/json';
    ctx.body = body
  } catch (error) {
    console.log(error)
    ctx.body = '请检查url';
    ctx.status = 404;
  }
}

// async function getBySBBH(table, sbbh) {
//   return await ctx.app.mssqlPool.query(`SELECT * FROM [dbo].[${table}] where sbbh in ('${sbbh.jion("','")}')`)
// }